<?php
/*
  $Id: index.php $
  TomatoCart Open Source Shopping Cart Solutions
  http://www.tomatocart.com

  Copyright (c) 2009 Wuxi Elootec Technology Co., Ltd;  Copyright (c) 2006 osCommerce

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License v2 (1991)
  as published by the Free Software Foundation.
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $osC_Language->getTextDirection(); ?>" xml:lang="<?php echo $osC_Language->getCode(); ?>" lang="<?php echo $osC_Language->getCode(); ?>">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $osC_Language->getCharacterSet(); ?>" />
<meta http-equiv="x-ua-compatible" content="ie=7" />
<link rel="shortcut icon" href="templates/<?php echo $osC_Template->getCode(); ?>/images/tomatocart.ico" type="image/x-icon" />

<title><?php echo ($osC_Template->hasMetaPageTitle() ? $osC_Template->getMetaPageTitle() . ' - ' : '') . STORE_NAME; ?></title>
<base href="<?php echo osc_href_link(null, null, 'AUTO', false); ?>" />

<link rel="stylesheet" type="text/css" href="templates/<?php echo $osC_Template->getCode(); ?>/stylesheet.css" />
<link rel="stylesheet" type="text/css" href="ext/autocompleter/Autocompleter.css" />
<script type="text/javascript" src="templates/<?php echo $osC_Template->getCode(); ?>/javascript/boxover.js"></script>
<!--[if IE]>
<style type="text/css">
  #productInfoTab a {
    top:11px;
  }
  
  #productInfoTab a.unselect {
    top:13px;
  }
</style>
<![endif]-->
<?php
  if ($osC_Template->hasPageTags()) {
    echo $osC_Template->getPageTags();
  }

  if ($osC_Template->hasJavascript()) {
    $osC_Template->getJavascript();
  }
  
  if ($osC_Template->hasStyleSheet()) {
    $osC_Template->getStyleSheet();
  }
?>

<meta name="Generator" content="TomatoCart" />
</head>
<body>
<div id="mainbg">
<?php
  if ($osC_Template->hasPageHeader()) {
?>

<div id="pageHeader">
  <div id="headerBar">
  <div class="logo">
    <?php
      echo osc_link_object(osc_href_link(FILENAME_DEFAULT), osc_image($osC_Template->getLogo(), STORE_NAME), 'id="siteLogo"');
    ?>
	</div>
  <div id="menu-top">   
    <ul>
      <li>
        <?php echo osc_link_object(osc_href_link(FILENAME_ACCOUNT, 'wishlist', 'SSL'), $osC_Language->get('my_wishlist')); ?>
      </li>
    <?php if ($osC_Customer->isLoggedOn()) { ?>
      <li>
        <?php echo osc_link_object(osc_href_link(FILENAME_ACCOUNT, 'logoff', 'SSL'), $osC_Language->get('logoff')); ?>
      </li>
    <?php } else { ?>
      <li>
        <?php echo osc_link_object(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL'), $osC_Language->get('login')); ?>
      </li>
       <li>
        <?php echo osc_link_object(osc_href_link(FILENAME_ACCOUNT, 'create', 'SSL'), $osC_Language->get('create_account')); ?>
      </li>
    <?php } ?>
    <?php if ((MAINTENANCE_MODE == 1) && isset($_SESSION['admin'])) { ?>
      <li id="admin_logout">
        <?php echo osc_link_object(osc_href_link(FILENAME_DEFAULT, 'maintenance=logoff', 'SSL'), $osC_Language->get('admin_logout')); ?>
      </li>
    <?php } ?>
      <li id="bookmark"></li>    
      
    </ul>	
	</div>
	
	<div id="menu-logo">  
	<ul id="menu-list">      	  
	<li>
	<?php   echo '<span class="' . ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' ? 'nav-left-visited' : 'nav-left') .'">';
			echo '<span class="' . ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' ? 'nav-right-visited' : 'nav-right') . '">';
			echo osc_link_object(osc_href_link(FILENAME_DEFAULT, 'index'), $osC_Language->get('home')) . '</span></span>' ;?>      
			
	  </li>
	<li>
	<?php  
			echo '<span class="' . ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' ? 'nav-left-visited' : 'nav-left') .'">';
			echo '<span class="' . ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' ? 'nav-right-visited' : 'nav-right') . '">';
			echo osc_link_object(osc_href_link(FILENAME_DEFAULT, 'index'), $osC_Language->get('gioi_thieu')) . '</span></span>' ;?>      			
	  </li>
	<li>
	<?php  
			echo '<span class="' . ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' ? 'nav-left-visited' : 'nav-left') .'">';
			echo '<span class="' . ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' ? 'nav-right-visited' : 'nav-right') . '">';
			echo osc_link_object(osc_href_link(FILENAME_DEFAULT, 'index'), $osC_Language->get('tin_tuc')) . '</span></span>' ;?>      			
	  </li>	
    <li>
	<?php  
	echo '<span class="' . ($osC_Template->getGroup() == 'specials' && $osC_Template->getModule() == 'specials' ? 'nav-left-visited' : 'nav-left') .'">';
	echo '<span class="' . ($osC_Template->getGroup() == 'specials' && $osC_Template->getModule() == 'specials' ? 'nav-right-visited' : 'nav-right') . '">';
	echo osc_link_object(osc_href_link(FILENAME_ACCOUNT, 'specials','SSL'), $osC_Language->get('specials')) . '</span></span>' ;?>      			
	</li>  	
	 <li>
	<?php  
	echo '<span class="' . ($osC_Template->getGroup() == 'compare' && $osC_Template->getModule() == 'compare' ? 'nav-left-visited' : 'nav-left') .'">';
	echo '<span class="' . ($osC_Template->getGroup() == 'compare' && $osC_Template->getModule() == 'compare' ? 'nav-right-visited' : 'nav-right') . '">';
	echo osc_link_object(osc_href_link(FILENAME_ACCOUNT, 'compare','SSL'), $osC_Language->get('compare')) . '</span></span>' ;?>      			
	</li>  
	<li>
	<?php  
			echo '<span class="' . ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' ? 'nav-left-visited' : 'nav-left') .'">';
			echo '<span class="' . ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' ? 'nav-right-visited' : 'nav-right') . '">';
			echo osc_link_object(osc_href_link(FILENAME_DEFAULT, 'index'), $osC_Language->get('contact_us')) . '</span></span>' ;?>      			
	</li>
<li>
	<?php  
			echo '<span class="' . ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' ? 'nav-left-visited' : 'nav-left') .'">';
			echo '<span class="' . ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' ? 'nav-right-visited' : 'nav-right') . '">';
			echo osc_link_object(osc_href_link(FILENAME_DEFAULT, 'index'), $osC_Language->get('huong_dan')) . '</span></span>' ;?>      			
	</li>  	  	     
    </ul>	  
	</div>
  </div> <!-- end headerbar -->
  
  
  
</div>

<?php
}
?>



<div id="pageWrapper">  
  <table id="pageBlockLeft" cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
  <?php
    $content_left = $osC_Template->getBoxGroup('left');
    if (!empty($content_left)) {
  ?>
    <td id="pageColumnLeft" valign="top">
      <div class="boxGroup">
      <?php
          echo $content_left;
      ?>  	  
      </div>
    </td>
  <?php
    } else {
  ?>
    <style type="text/css"><!--
      #pageContent {
        
      }
    //--></style>
  <?php
    }
  ?>
    <td id="pageContent"  valign="top">	
	<div class="search">
	<div class="search-left">
	<div class="search-right">
	
	<div id="search-content">	
	<form name="search" action="<?php echo osc_href_link(FILENAME_SEARCH, null, 'NONSSL', false);?>" method="get">
    <ul>
	<li>
	<?php echo osc_draw_input_field('keywords', null, 'value="Nhập tên sản phẩm" title="Nhập tên sản phẩm"
	   onblur="if (this.value==\'\') this.value=\'Nhập tên sản phẩm\';" onfocus="if (this.value==\'Nhập tên sản phẩm\') this.value=\'\';" '); ?>
	</li>
      <li style="display:none;">

<?php
  //echo osc_draw_label($osC_Language->get('field_search_categories'), 'cPath');

  $osC_CategoryTree->setSpacerString('&nbsp;', 2);

  $categories_array = array(array('id' => '', 'text' => $osC_Language->get('filter_all_categories')));

  foreach ($osC_CategoryTree->buildBranchArray(0) as $category) {
    $categories_array[] = array('id' => $category['id'],
                                'text' => $category['title']);
  }

  echo osc_draw_pull_down_menu('cPath', $categories_array);
?>

      </li>
      <li style="display:none"><?php echo osc_draw_checkbox_field('recursive', array(array('id' => '1', 'text' => $osC_Language->get('field_search_recursive'))), true); ?>
	  </li>
      <li>

<?php
  //echo osc_draw_label($osC_Language->get('field_search_manufacturers'), 'manufacturers');
  $manufacturers_array = array(array('id' => '', 'text' => $osC_Language->get('filter_all_manufacturers')));
  $Qmanufacturers = $osC_Database->query('select manufacturers_id, manufacturers_name from :table_manufacturers order by manufacturers_name');
  $Qmanufacturers->bindTable(':table_manufacturers', TABLE_MANUFACTURERS);
  $Qmanufacturers->execute();
  while ($Qmanufacturers->next()) {
    $manufacturers_array[] = array('id' => $Qmanufacturers->valueInt('manufacturers_id'),
                                   'text' => $Qmanufacturers->value('manufacturers_name'));
  }
  echo osc_draw_pull_down_menu('manufacturers', $manufacturers_array);
?>

      </li>
      <li><?php echo osc_draw_input_field('pfrom',null,'value="Giá từ" title="Giá từ"
	   onblur="if (this.value==\'\') this.value=\'0\';" onfocus="if (this.value==\'Giá từ\') this.value=\'\';" '); ?></li>
      <li><?php echo osc_draw_input_field('pto',null,'value="Giá đến" title="Giá đến"
	   onblur="if (this.value==\'\') this.value=\'0\';" onfocus="if (this.value==\'Giá đến\') this.value=\'\';" '); ?></li>
	   <li>
	   <?php echo osc_draw_image_submit_button('button_search.png', $osC_Language->get('button_search')); ?>
	   </li>
    </ul>
	</form>
	
	</div>
	<div class="cart">
        <?php echo osc_link_object(osc_href_link(FILENAME_CHECKOUT, null, 'SSL'), '<span id="popupCart">' . osc_image('templates/' . $osC_Template->getCode() . '/images/shopping_cart_icon.png') . '<span id="popupCartItems">' . $osC_ShoppingCart->numberOfItems() . '</span>' . '<span>' . $osC_Language->get('text_items') . '</span></span>') ; ?>
      </div>
	</div>
	</div>
	</div>
<?php if($osC_Template->getContentGroup('slideshow')){ ?>	
<div id="slideShow">
  <?php 
    $slideshow = $osC_Template->getContentGroup('slideshow');
    if ($slideshow !== false) {
      echo $slideshow;
    }
  ?>  
</div>	
<?php
}
      if ($osC_Services->isStarted('breadcrumb')) {
  ?>
      <div id="breadcrumbPath">
      <?php
        echo $breadcrumb->trail(' &raquo; ');
      ?>        		
      </div>
  <?php
    }
  ?>	
	
      <?php
        if ($messageStack->size('header') > 0) {
          echo $messageStack->output('header');
        }

        if ($osC_Template->hasPageContentModules()) {
          foreach ($osC_Services->getCallBeforePageContent() as $service) {
            $$service[0]->$service[1]();
          }

          $content_before = $osC_Template->getContentGroup('before');
          if (!empty($content_before)) {
            echo $content_before;
          }
        }

        if ($osC_Template->getCode() == DEFAULT_TEMPLATE) {
          include('templates/' . $osC_Template->getCode() . '/content/' . $osC_Template->getGroup() . '/' . $osC_Template->getPageContentsFilename());
        } else {
          if (file_exists('templates/' . $osC_Template->getCode() . '/content/' . $osC_Template->getGroup() . '/' . $osC_Template->getPageContentsFilename())) {
            include('templates/' . $osC_Template->getCode() . '/content/' . $osC_Template->getGroup() . '/' . $osC_Template->getPageContentsFilename());
          } else {
            include('templates/' . DEFAULT_TEMPLATE . '/content/' . $osC_Template->getGroup() . '/' . $osC_Template->getPageContentsFilename());
          }
        }
      ?>

      <div style="clear: both;"></div>

      <?php
        if ($osC_Template->hasPageContentModules()) {
          foreach ($osC_Services->getCallAfterPageContent() as $service) {
            $$service[0]->$service[1]();
          }
        
          $content_after = $osC_Template->getContentGroup('after');
          if (!empty($content_after)) {
            echo $content_after;
          }
        }
      ?>

    </td>
  <?php
    $content_right = $osC_Template->getBoxGroup('right');
  ?>
  <?php
    if (!empty($content_right)) {
  ?>
      <td id="pageColumnRight"  valign="top">
        <div class="boxGroup">
      <?php
          echo $content_right;
      ?>
        </div>
      </td>

  <?php
    } elseif ( empty($content_right) && empty($content_left) ) {
  ?>
     
  <?php
    } elseif ( empty($content_right) ) {
  ?>
      <style type="text/css"><!--
      #pageContent {
        
      }

      #pageBlockLeft{
        width:100%;
      }
      //--></style>
  <?php
    }

    unset($content_left);
    unset($content_right);
  ?>
  </tr>
  </table>


</div>

<?php 
  if ($osC_Template->hasPageFooter()) {
?>

  <div id="pageFooter">
  <div style="text-align:center;"><img src="templates/<?php echo $osC_Template->getCode(); ?>/images/logo-bottom.png"/></div>    
    
    <p style="margin: 3px;">
      <?php
        echo sprintf($osC_Language->get('footer'), date('Y'), osc_href_link(FILENAME_DEFAULT), STORE_NAME);
      ?>
    </p>
  </div>
  
<?php 
    if ($osC_Services->isStarted('banner') && $osC_Banner->exists('468x60')) {
      echo '<p align="center">' . $osC_Banner->display() . '</p>';
    }
  }
?>

<script type="text/javascript" src="ext/autocompleter/Autocompleter.js"></script>
<script type="text/javascript" src="ext/autocompleter/Autocompleter.Request.js"></script>
<script type="text/javascript" src="ext/autocompleter/Observer.js"></script>
<script type="text/javascript" src="includes/javascript/auto_completer.js"></script>
<script type="text/javascript" src="includes/javascript/popup_cart.js"></script>
<script type="text/javascript" src="includes/javascript/bookmark.js"></script>

<script type="text/javascript">
  window.addEvent('domready', function() {
    new PopupCart({
      template: '<?php echo $osC_Template->getCode(); ?>',
      sessionName: '<?php echo $osC_Session->getName(); ?>',
      sessionId: '<?php echo $osC_Session->getID(); ?>'
    });
    
    new TocAutoCompleter('keywords', {
      sessionName: '<?php echo $osC_Session->getName(); ?>',
      sessionId: '<?php echo $osC_Session->getID(); ?>',
      template: '<?php echo $osC_Template->getCode(); ?>',
      width: 300
    });
  });
  new TocBookmark({
  	bookmark: 'bookmark',
  	text: '<?php echo $osC_Language->get('bookmark'); ?>',
    img: '<?php echo 'images/bookmark.png'; ?>'
  });  
</script>

<?php 
  if ($osC_Services->isStarted('google_analytics')) {
    echo SERVICES_GOOGLE_ANALYTICS_CODE;
  }
?>

<?php
  if ($osC_Services->isStarted('piwik')) {
    echo $toC_Piwik->renderJs();
  }
?>
</div>
</body>
</html>